{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import MalardClient.DataSetQuery as md\n",
    "import datetime\n",
    "\n",
    "#Sets the URL of the Malard ServiceGateway.\n",
    "query = md.DataSetQuery('http://localhost:9000','MALARD-PROD')\n",
    "\n",
    "#Sets the output directory for all users of the server.\n",
    "#query.createEnvironment('DEV','/data/puma1/scratch/malard/export/','/data/puma1/scratch/malard/mask/','/data/snail1/scratch/malard/points/')\n",
    "#query.createEnvironment('JALOCALv3','C:\\\\Earthwave\\\\malard\\\\export\\\\','C:\\\\Earthwave\\\\malard\\\\masks\\\\','C:\\\\Earthwave\\\\malard\\\\Points\\\\','mongodb://localhost:27017','C:\\\\Earthwave\\\\malard\\\\intermediate\\\\')\n",
    "\n",
    "#query.createEnvironment('DEVv2','/data/puma1/scratch/v2/malard/export/','/data/puma1/scratch/v2/malard/mask/','/data/snail1/scratch/v2/malard/points/','mongodb://localhost:27018','/data/puma1/scratch/v2/malard/intermediate/', '/data/eagle/data-holding', '/data/eagle/' )\n",
    "\n",
    "#query.createEnvironment('DEV_G','/data/puma1/scratch/v2/malard/export/','/data/puma1/scratch/v2/malard/mask/','/data/eagle/data-scratch/v2/malard/points/','mongodb://localhost:27018','/data/puma1/scratch/v2/malard/intermediate/')\n",
    "\n",
    "#query.createEnvironment('DEV_SLUG','/data/puma1/scratch/v2/malard/export/','/data/puma1/scratch/v2/malard/mask/','/data/slug/scratch/v2/malard/points/','mongodb://localhost:27018','/data/puma1/scratch/v2/malard/intermediate/', '/data/eagle/data-holding')\n",
    "\n",
    "\n",
    "#query.createEnvironment('DEV_EXT','/data/puma1/scratch/v2/malard/export/','/data/puma1/scratch/v2/malard/mask/','/media/earthwave/MalardExt/Malard','mongodb://localhost:27018','/data/puma1/scratch/v2/malard/intermediate/', '/data/eagle/data-holding/', '/data/eagle/')\n",
    "\n",
    "query.createEnvironment('MALARD-PROD','/data/puma/scratch/malard/export/','/data/puma/scratch/malard/mask/','/data/snail/scratch/malard/points/','mongodb://localhost:27018','/data/puma/scratch/malard/intermediate/', '/data/eagle/data-holding/', '/data/eagle/')\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "print(query.getEnvironment( \"MALARD-PROD\" ))\n",
    "\n",
    "#print( query.getEnvironment('DEVv2'))\n",
    "#print( query.getEnvironment('DEV'))\n",
    "#print( query.getEnvironment('JALOCALv3'))\n",
    "\n",
    "#print( query.getProjectionFromShortName('APS'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "projections = { 'NPS':  {'proj4' : '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs','conditions':['>=52']},\n",
    "                'HMA': {'proj4' : '+proj=aea +lat_1=25 +lat_2=47 +lat_0=36 +lon_0=85 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs','conditions':['>=20','<=50']},\n",
    "                'PAT': {'proj4' : '+proj=aea +lat_1=-55 +lat_2=-45 +lat_0=-50 +lon_0=-70 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_def','conditions':['>-60','<=-30']},\n",
    "                'APS': {'proj4' : '+proj=stere +lat_0=-90 +lat_ts=-71 +lon_0=0 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs','conditions':['<=-60']},\n",
    "                'ICE' : {'proj4': '+proj=stere +lat_0=90 +lat_ts=70 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs','conditions':['>=52']}\n",
    "                }\n",
    "\n",
    "for shortName, parameters in projections.items():\n",
    "    print(query.publishProjection(shortName, parameters['proj4'], parameters['conditions'] ))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "\n",
    "parents = ['test','cryotempo','mtngla']\n",
    "\n",
    "regions = { 'alaska':'NPS','antarctic':'APS','greenland':'NPS','himalayas':'HMA', 'iceland' : 'ICE'}\n",
    "\n",
    "for p in parents:\n",
    "    for region,shortName in regions.items():\n",
    "        query.publishProjectionRegionMapping(p,region,shortName)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "query.getProjection('cryotempo','iceland')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
